let connection = require("../dbutil/dbutil");
let myModule = require("./my-module");

function checkInfo(id, token, callback) {
    let sql = "select username from user where uid = ? and token = ?";
    let sqlparams=[id, token]
    connection.query(sql,sqlparams, function (err, result) {
        if (err) {
            console.log(err);
        } else {
            let ret = {
                code: 1002,
                user: "",
            }
            if (result.length > 0 && myModule.verifyToken(token)) {
                ret = {
                    code: 1001,
                    user: result[0].username,
                }
            }
            callback(ret)
        }
    })
}

exports.checkInfo = checkInfo;